<?php

namespace App\Models;

use App\Models\base\FengtModel;
use App\Models\base\WarehouseModel;
use App\Models\dispatch\CarModel;
use App\Models\dispatch\DriverModel;
use App\Models\dispatch\UnloadModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class DispatchTaskRecordModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_dispatch_task_record';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';

    const TYPE = ['start' => '开始运输', 'pass' => '经停地', 'end' => '卸货地'];
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];


    //仓库地址
    public function warehouse(): BelongsTo {
        return $this->belongsTo(WarehouseModel::class, 'warehouse_id');
    }

    //卸货点
    public function unload(): BelongsTo {
        return $this->belongsTo(UnloadModel::class, 'warehouse_id');
    }

    //司机
    public function driver(): BelongsTo {
        return $this->belongsTo(DriverModel::class, 'driver_id');
    }


}
